<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/oApublic.css">
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_1435664_dscbzfq8qt6.css">
    <link rel="stylesheet" href="./css/addschool.css">
    <style>
        .addRecord {
            display: none;
        }

        .submit {
            display: none;
        }

        .addRival span {
            display: none;
        }

        .iframeHead i {
            float: right;
            margin-right: 30px;
            color: #3c9688;
            cursor: pointer;
        }

        .iframeHead i:hover {
            color: #43b3a2;
        }
    </style>
</head>

<body>
    <div class="iframeHead clear"><span>院校管理</span><em>/ 院校信息</em><i class="icon iconfont icon-xiugai07">修改信息</i></div>
    <div class="content clear">
        <div class="clear">
            <div class="left clear">
                <h3>基本信息</h3>
                <div class="schoolNameDiv">
                    <label>院校名称</label>
                    <div class="inp"><input type="text" placeholder="请输入院校名称" name="schoolName" id="schoolName"></div>
                </div>
                <div class="clear">
                    <div class="departmentDiv">
                        <label>院系</label>
                        <div class="inp"><input type="text" placeholder="请输入院系" name="department" id="department"></div>
                    </div>
                    <div class="eductionDiv">
                        <label>学制</label>
                        <div class="inp"><input type="text" placeholder="学制" name="eduction" id="eduction"></div>
                    </div>
                </div>
                <div class="clear">
                    <div class="areaDiv">
                        <label>所在地区</label>
                        <div class="inp" id="provinceDiv">
                            <select name="province" id="province">
                                <option disabled selected hidden></option>
                            </select>
                            <span class="icon iconfont icon-xia"></span>
                        </div>
                        <div class="inp" id="cityDiv">
                            <select name="city" id="city">
                            </select>
                            <span class="icon iconfont icon-xia"></span>
                        </div>
                    </div>
                    <div class="branchDiv">
                        <label>所属部门</label>
                        <div class="inp"><input type="text" placeholder="所属部门" name="branch" id="branch"></div>
                    </div>
                </div>
                <div class="addressDiv">
                    <label>院校地址</label>
                    <div class="inp"><input type="text" placeholder="请输入院校地址" name="address" id="address"></div>
                </div>
                <div class="synopsisDiv">
                    <label>院校简介</label>
                    <div class="inp"><input type="text" placeholder="请输入院校简介" name="synopsis" id="synopsis"></div>
                </div>
                <h3>院系联系人</h3>
                <div class="linkNameDiv">
                    <label class="long">院系联系人姓名</label>
                    <div class="inp"><input type="text" placeholder="院系联系人电话" name="linkName" id="linkName"></div>
                </div>
                <div class="linkTelDiv">
                    <label class="long">院系联系人电话</label>
                    <div class="inp"><input type="text" placeholder="院系联系人电话" name="linkTel" id="linkTel"></div>
                </div>
            </div>
            <div class="right">
                <h3>学生数据信息</h3>
                <div class="clear">
                    <div class="targetDiv">
                        <label class="middle">目标学生数量</label>
                        <div class="inp"><input type="text" placeholder="目标学生数量" name="target" id="target"></div>
                    </div>
                    <div class="expectDiv">
                        <label class="middle">预计报名人数</label>
                        <div class="inp"><input type="text" placeholder="预计报名人数" name="expect" id="expect"></div>
                    </div>
                    <div class="realNumberDiv">
                        <label class="middle">实际招生人数</label>
                        <div class="inp"><input type="text" placeholder="实际招生人数" name="realNumber" id="realNumber">
                        </div>
                    </div>
                    <div class="leaveTimeDiv">
                        <label class="middle">学生离校时间</label>
                        <div class="inp"><i class="icon iconfont icon-rili" style="margin-left: 5px"></i><input
                                type="text" placeholder="学生离校时间" name="leaveTime" id="leaveTime"></div>
                    </div>
                    <div class="activeModDiv">
                        <label class="middle">预计活动方式</label>
                        <div class="inp">
                            <select name="activeMod" id="activeMod">
                                <option value="实训">实训</option>
                                <option value="讲座">讲座</option>
                                <option value="宣讲">宣讲</option>
                            </select>
                            <span class="icon iconfont icon-xia"></span>
                        </div>
                    </div>
                    <div class="activeTimeDiv">
                        <label class="middle">计划活动时间</label>
                        <div class="inp"><i class="icon iconfont icon-rili" style="margin-left: 5px"></i><input
                                type="text" placeholder="计划活动时间" name="activeTime" id="activeTime"></div>
                    </div>
                </div>
                <h3>考研/专升本比例</h3>
                <div class="clear">
                    <div class="postGraduateDiv">
                        <label class="middle">考研比例</label>
                        <div class="inp"><input type="text" placeholder="考研比例" name="postGraduate" id="postGraduate">
                        </div>
                    </div>
                    <div class="underGraduateDiv">
                        <label class="middle">专升本比例</label>
                        <div class="inp"><input type="text" placeholder="专升本比例" name="underGraduate" id="underGraduate">
                        </div>
                    </div>
                </div>
                <h3>本公司以往招生信息</h3>
                <div class="clear">
                    <div class="pastWayDiv">
                        <label class="middle">以往活动方式</label>
                        <div class="inp"><input type="text" placeholder="以往活动方式" name="pastWay" id="pastWay"></div>
                    </div>
                    <div class="pastNumberDiv">
                        <label class="middle">以往培训数量</label>
                        <div class="inp"><input type="text" placeholder="以往培训数量" name="pastNumber" id="pastNumber">
                        </div>
                    </div>
                    <div class="pastSumDiv">
                        <label class="middle">以往招生总数</label>
                        <div class="inp"><input type="text" placeholder="以往招生总数" name="pastSum" id="pastSum">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="footer">
            <h3 class="addRival">竞争对手<span class="icon iconfont icon-jiahao">添加</span></h3>
            <div class="rivalInfor clear">

            </div>
            <h3>记录信息</h3>
            <div class="record">
                <div class="recordDetailDiv">
                    <label>记录内容</label>
                    <textarea name="recordDetail" id="recordDetail" cols="30" rows="10"
                        placeholder="请输入记录详情"></textarea>
                </div>
                <div class="addRecord">
                    <span class="icon iconfont icon-jiahao">添加记录</span>
                </div>
            </div>
            <div class="submit">
                <span class="icon iconfont icon-tijiao">提交</span>
            </div>
        </div>
    </div>
</body>
<script src="./js/jquery-3.4.1.js"></script>
<script src="laydate/laydate.js"></script>
<script src="./js/schoolJson.js"></script>
<script src="./js/oApublic.js"></script>
<script src="./js/schoolTime.js"></script>
<script>
    $('input').attr('disabled', 'true');
    $('.inp').css('backgroundColor', '#f2f2f2');
    $('input').css({ cursor: 'not-allowed', backgroundColor: '#f2f2f2' });
    $('select').attr('disabled', 'true');
    $('select').css({ cursor: 'not-allowed', backgroundColor: '#f2f2f2' });
    $('.iframeHead i').on('click', function () {
        $('input').removeAttr('disabled');
        $('.inp').css('backgroundColor', '#fff');
        $('input').css({ cursor: 'auto', backgroundColor: '#fff' });
        $('select').removeAttr('disabled');
        $('select').css({ cursor: 'auto', backgroundColor: '#fff' });
        $(".addRecord").css("display", "block");
        $(".submit").css("display", "block");
        $(".addRival span").css("display", "block");
        //执行一个laydate实例
        laydate.render({
            elem: '#leaveTime'
            //指定元素
        });
        laydate.render({
            elem: '#activeTime'
            //指定元素
        });
        rotateXia('#activeMod')
        rotateXia('#city');
        rotateXia('#province');
    })
    $(function () {
        $.ajax({
            url: schoolUrl,
            type: "get",
            dataType: "json",
            data: {
                "method": "province",
            },
            success: function (data) {
                if (data.code == 100) {
                    console.log(data);
                    var list = data.result;
                    for (var i = 0; i < list.length; i++) {
                        var oPtion = $('<option></option>');
                        $(oPtion).html(list[i].name);
                        $(oPtion).val(list[i].id);
                        $(oPtion).appendTo($('#province'));
                    }
                }
            },
            error: function (xhr, ero) {
                console.log(ero);
            }
        });
    });
    $("#province").change(function () {
        $('#city').html('');
        addressPro = $('#province').find("option:selected").html();
        addressCity = '';
        $('#address').val(addressPro + addressCity);
        var oProvince = $('#province').find("option:selected").val();
        $.ajax({
            url: schoolUrl,
            type: "get",
            dataType: "json",
            data: {
                "method": "cityandarea",
                "parent_id": oProvince,
            },
            success: function (data) {
                if (data.code == 100) {
                    console.log(data);
                    var list = data.result;
                    for (var i = 0; i < list.length; i++) {
                        var oPtion = $('<option></option>');
                        $(oPtion).html(list[i].name);
                        $(oPtion).val(list[i].id);
                        $(oPtion).appendTo($('#city'));
                    }
                }
            },
            error: function (xhr, ero) {
                console.log(ero);
            }
        });
    });
    $('#cityDiv').on('change', function () {
        addressCity = $('#city').find("option:selected").html();
        $('#address').val(addressPro + addressCity);
    });

    addiNcident('.activeModDiv input', '.activeModDiv .option');
    $('.activeModDiv .inp').on('click', 'li', function () {
        $(this).parent().siblings('input').val($(this).html());
    });
    $(function(){
        $.ajax({
            url: schoolUrl,
            type:'get',
            dataType:'json',
            data:{
                "method":"oneschool",
                "id":localStorage.listId,
            },
            success:function(data){
                console.log(data);
                var result = data.result;
                $("#schoolName").val(result.schoolName);
                $("#department").val(result.department);
                $("#eduction").val(result.education);
                $('#address').val(result.address);
                $("#branch").val(result.competentDept);
                $("#synopsis").val(result.desc);
                $("#target").val(result.targetStudentSum);
                $("#expect").val(result.planRecruitNum);
                $("#realNumber").val(result.realityNum);
                $("#leaveTime").val(timestampToTime(result.leaveTime));
                $("#activeMod").find("option:contains("+result.planActivity+")").attr("selected", true);
                $("#activeTime").val(result.activityTime);
                $("#pastWay").val(result.beforeActivity);
                $("#postGraduate").val(result.postgraduateExam);
                $("#underGraduate").val(result.topUpExam);
                var depart = JSON.parse(result.departConnection);
                $("#linkName").val(depart.name);
                $("#linkTel").val(depart.tel);
            },
            error:function(xhr,error){
                console.log(error);
            }
        })
    })
    $(".submit").on("click", function () {
        var departperson = {
            "name": $("#linkName").val(),
            "tel": $("#linkTel").val(),
        };
        var depart = String(departperson);
        var competeperson = {
            firmName: $(".firmName").val(),
            firmSubject: $(".firmSubject").val(),
            tuition: $(".tuition").val(),
            recruitWay: $(".recruitWay").val(),
            recruitNum: $(".recruitNum").val(),
        };
        var compete = JSON.stringify(competeperson);
        console.log(departperson);
        $.ajax({
            url: schoolUrl,
            type: "get",
            data: {
                "method": "updateschool",
                "schoolName": $("#schoolName").val(),
                "competentDept": $("#branch").val(),
                "address": $('#address').val(),
                "education": $("#eduction").val(),
                "desc": $("#synopsis").val(),
                "department": $("#department").val(),
                "departConnection": depart,
                "modifyId": localStorage.getItem("empId"),
                "targetStudentSum": $("#target").val(),
                "beforeStudySum": $("#pastNumber").val(),
                "postgraduateExam": $("#postGraduate").val(),
                "topUpExam": $("#underGraduate").val(),
                "competition": compete,
                "beforeRecruitNum": $("#pastSum").val(),
                "beforeActivity": $("#pastWay").val(),
                "planActivity": $("#activeMod").find("option:selected").val(),
                "planRecruitNum": $("#expect").val(),
                "activityTime": $("#activeTime").val(),
                "leaveTime": $("#leaveTime").val(),
                "realityNum": $("#realNumber").val(),
                "regionId": $('#city').find("option:selected").val(),
                "recordContent": $("#recordDetail").val(),
            },
            dataType: "json",
            success: function (data) {
                window.location = "./school.html";
                console.log(data);
            },
            error: function (xhr, error) {
                console.log(error);
            }
        })
    })
    $('.iframeHead span').on('click', function () {
        window.location = './school.html';
    })
</script>

</html>